<!DOCTYPE html>
<html>
<head>
    <title>清单解析</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="/res/third/easyUI/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css" />
    <script src="/res/js/common/jquery.1.9.1.min.js"></script>
    <script src="/res/third/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="/res/third/laytpl/template.js" type="text/javascript"></script>
    <script src="/res/third/layer/layer.js"></script>
    <script src="/res/third/layer/layer.extends.js"></script>

    <style>
        .noselect{
            background-color: rgba(99, 230, 99, 0.8);
        }
        .w120{
            width:120px;
        }

        .achecked{
            background-color: green;
        }
        .panel-body.panel-body-noheader.panel-body-noborder{
            overflow-y: hidden;
        }
    </style>
</head>


<body id="easyui-layout"  class="easyui-layout"  >
<div data-options="region:'north'" >
    <div>
        <button onclick="validAll()" class="btn  btn-sm btn-success" style="margin: 5px;"  >合并提交</button>
        <span style="color: red;" >*删除tab表示该tab内的全部舍弃</span>
    </div>
</div>
<div data-options="region:'center',split:false">
    <div id="excelTab" class="easyui-tabs" fit="true" border="false">

    </div>
</div>
<script>


    function validAll() {

        var flag = false;
        var data =null;
        $("iframe[name='excelframe']").each(function (i) {
            var iframe = $(this)[0];
            flag = iframe.contentWindow.validBeforeSub();
            if(!flag){
                var name = $(this).attr("class");
                $('#excelTab').tabs('select', name);
                return false;
            }else{
                var obj = iframe.contentWindow.createData();
                if(data==null){
                    data=obj;
                }else{
                    $.each(obj.item,function () {
                        data.item.push(this);
                    });

                    $.each(obj.typenames,function () {
                        data.typenames.push(this);
                    });

                    $.each(obj.oldtitles,function () {
                        data.oldtitles.push(this);
                    });
                }
            }
        });

        if(flag){
            layer.post({
                url:"/enquiry/o_analy_saveitem.do",
                data:JSON.stringify(data),
                contentType:"application/json",
                success:function(result){
                    if(result.success){
                        //更新原
                        layer.alert("操作成功",function(){
                            window.opener.location.reload();
                            layer.closeAll();
                            layer.load(2,{shade:0.1});
                            window.setTimeout(function () {
                                window.close();
                            },1000);

                        });
                    }else{
                        layer.msgShort(result.msg);
                    }
                }
            });

        }
    }

    $('#excelTab').tabs({
        border:false
    });


    function addTabExcel(subtitle, url,i) {
        if (!$('#excelTab').tabs('exists', subtitle)) {
            $('#excelTab').tabs('add',{
                title : subtitle,
                content : createFrameExcel(url,i),
                closable : true
            });
        }
        return false;
    }
    function createFrameExcel(url,i) {
        var s = '<iframe  class="excel_model_'+i+'"  name="excelframe"  frameborder="no" border="0″ marginwidth="0″ marginheight="0″ scrolling="no" allowtransparency="yes"  height="100%"  src="'+url+'" style="width:100%;height:100%;"></iframe>';
        return s;
    }

    var mulitysize = ${wrapsize!0};
    for(var i=0;i<mulitysize;i++){
        addTabExcel("excel_model_"+i,"/enquiry/mulity_one?index="+i,i);
    }

    //$("#easyui-layout").layout('resize', {});
</script>
</body>
</html>